package com.droowa.model.service;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.droowa.domain.ShopManager;
import com.droowa.model.dao.ShopManagerDAO;

@Service
public class ShopManagerServiceImpl implements ShopManagerService{
	
	@Autowired
	private ShopManagerDAO dao;
	
	@Override
	public int joinShopManager(ShopManager shopManager) throws SQLException {
		if(getShopManagerBySort(shopManager.getSort()).size()>=1){
			int update = modifyShopManager(shopManager);
			if(update==1){
				return -1;
			}else{
				return 0;
			}
		}
		return dao.insertShopManager(shopManager);
	}

	@Override
	public int removeShopManagerById(String shopManagerId) throws SQLException {
		return dao.deleteShopManagerById(shopManagerId);
	}

	@Override
	public int modifyShopManager(ShopManager shopManager) throws SQLException {
		return dao.updateShopManager(shopManager);
	}

	@Override
	public ShopManager getShopManagerByShopManagerId(String shopManagerId)
			throws SQLException {
		return dao.selectShopManagerByShopManagerId(shopManagerId);
	}

	@Override
	public List<ShopManager> getShopManagerByName(String name)
			throws SQLException {
		return dao.selectShopManagerByName(name);
	}

	@Override
	public List<ShopManager> getShopManagerByEmail(String email)
			throws SQLException {
		return dao.selectShopManagerByEmail(email);
	}

	@Override
	public List<ShopManager> getShopManagerBySort(String sort)
			throws SQLException {
		return dao.selectShopManagerBySort(sort);
	}

	@Override
	public List<ShopManager> getShopManager() throws SQLException {
		return dao.selectShopManager();
	}	
	
}
